﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Target" type="Target" />
  <xs:simpleType name="Target">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Document" />
      <xs:enumeration value="Workflow" />
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="Operator" type="Operator" />
  <xs:simpleType name="Operator">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Or" />
      <xs:enumeration value="And" />
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="Condition" nillable="true">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="1" name="If">
          <xs:complexType>
            <xs:sequence>
              <xs:element minOccurs="0" maxOccurs="1" name="States" type="ArrayOfState" />
            </xs:sequence>
            <xs:attribute name="Operator" type="Operator" use="optional" />
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="Target" type="Target" use="required" />
      <xs:attribute name="IsFinalState" type="xs:boolean" use="required" />
      <xs:attribute name="StateMode" type="SelectionMode" use="optional" />
      <xs:attribute name="NewState" type="StateValue" use="required" />
    </xs:complexType>
  </xs:element>
  <xs:complexType name="ArrayOfState">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="State" nillable="true">
        <xs:complexType>
          <xs:attribute name="Target" type="Target" use="required" />
          <xs:attribute name="StateMode" type="SelectionMode" use="required" />
          <xs:attribute name="Value" type="StateValue" use="required" />
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="SelectionMode">
    <xs:restriction base="xs:string">
      <xs:enumeration value="One" />
      <xs:enumeration value="All" />
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="StateValue">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Started" />
      <xs:enumeration value="Validated" />
      <xs:enumeration value="Rejected" />
      <xs:enumeration value="Read" />
      <xs:enumeration value="Replied" />
      <xs:enumeration value="Aborted" />
      <xs:enumeration value="Indexed" />
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="WkfState" nillable="true">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="1" name="Actions" type="ArrayOfAction" />
      </xs:sequence>
      <xs:attribute name="Value" type="StateValue" use="required" />
    </xs:complexType>
  </xs:element>
  <xs:complexType name="ArrayOfAction">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="Action" nillable="true">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="1" name="Conditions" type="ArrayOfCondition" />
          </xs:sequence>
          <xs:attribute name="IsEnabled" type="xs:boolean" use="required" />
          <xs:attribute name="UiTypeAction" type="UiTypeAction" use="required" />
          <xs:attribute name="ValidatingMode" type="SelectionMode" use="optional" />
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="ArrayOfCondition">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="Condition" nillable="true">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="1" name="If">
              <xs:complexType>
                <xs:sequence>
                  <xs:element minOccurs="0" maxOccurs="1" name="States" type="ArrayOfState" />
                </xs:sequence>
                <xs:attribute name="Operator" type="Operator" use="optional" />
              </xs:complexType>
            </xs:element>
          </xs:sequence>
          <xs:attribute name="Target" type="Target" use="required" />
          <xs:attribute name="IsFinalState" type="xs:boolean" use="required" />
          <xs:attribute name="StateMode" type="SelectionMode" use="optional" />
          <xs:attribute name="NewState" type="StateValue" use="required" />
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="UiTypeAction">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Validate" />
      <xs:enumeration value="Read" />
      <xs:enumeration value="Refuse" />
      <xs:enumeration value="Reply" />
      <xs:enumeration value="Enveloping" />
      <xs:enumeration value="Cancel" />
      <xs:enumeration value="Index" />
    </xs:restriction>
  </xs:simpleType>
  <xs:element name="State" nillable="true">
    <xs:complexType>
      <xs:attribute name="Target" type="Target" use="required" />
      <xs:attribute name="StateMode" type="SelectionMode" use="required" />
      <xs:attribute name="Value" type="StateValue" use="required" />
    </xs:complexType>
  </xs:element>
  <xs:element name="SelectionMode" type="SelectionMode" />
  <xs:element name="Rules">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="1" name="WkfStates" type="ArrayOfWkfState" />
      </xs:sequence>
      <xs:attribute name="UseGlobalActionOnly" type="xs:boolean" use="required" />
    </xs:complexType>
  </xs:element>
  <xs:complexType name="ArrayOfWkfState">
    <xs:sequence>
      <xs:element minOccurs="0" maxOccurs="unbounded" name="WkfState" nillable="true">
        <xs:complexType>
          <xs:sequence>
            <xs:element minOccurs="0" maxOccurs="1" name="Actions" type="ArrayOfAction" />
          </xs:sequence>
          <xs:attribute name="Value" type="StateValue" use="required" />
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:element name="StateValue" type="StateValue" />
  <xs:element name="UiTypeAction" type="UiTypeAction" />
  <xs:element name="Action" nillable="true">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="1" name="Conditions" type="ArrayOfCondition" />
      </xs:sequence>
      <xs:attribute name="IsEnabled" type="xs:boolean" use="required" />
      <xs:attribute name="UiTypeAction" type="UiTypeAction" use="required" />
      <xs:attribute name="ValidatingMode" type="SelectionMode" use="optional" />
    </xs:complexType>
  </xs:element>
  <xs:element name="If" nillable="true">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="1" name="States" type="ArrayOfState" />
      </xs:sequence>
      <xs:attribute name="Operator" type="Operator" use="optional" />
    </xs:complexType>
  </xs:element>
</xs:schema>